/**
 * @function 中序遍历递归法，遍历顺序:左->中>右
*/

const inorderTraversal = (root) => {
  const res = []
  const preorder = root => {
    if (!root) return res
    res.push(root.val)
    preorder(root.left)
    preorder(root.right)
  }
  preorder(root)
  return res
}

const root = {
  val: 1,
  left: {
    val: 2,
    left: null,
    right: null
  },
  right: {
    val: 3,
    left: null,
    right: null
  }
}

console.log(inorderTraversal(root));